home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlib25 / mntlib25.zoo / _umulsi3.s < prev    next >
Text File  |  1992-06-01  |  785b  |  35 lines

  1. | unsigned long integer multiplication routine
  2. |
  3. | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  4. |
  5. |
  6. | Revision 1.1, kub 03-90
  7. | first version, replaces the appropriate routine from fixnum.s.
  8. | This one is short and fast for the common case of both longs <= 0x0000ffff,
  9. | but the case of a zero lowword is no longer recognized.
  10. | (besides it's easier to read this source 8-)
  11.  
  12.     .text
  13.     .even
  14.     .globl    __umulsi3, ___umulsi3
  15.  
  16. __umulsi3:
  17. ___umulsi3:
  18.     movel    d2,a0        | save registers
  19.     movel    d3,a1
  20.     movemw    sp@(4),d0-d3    | get the two longs. u = d0-d1, v = d2-d3
  21.     extl    d0        | u.h <> 0 ?
  22.     beq    1f
  23.     mulu    d3,d0        | r  = v.l * u.h
  24. 1:    tstw    d2        | v.h <> 0 ?
  25.     beq    2f
  26.     mulu    d1,d2        | r += v.h * u.l
  27.     addw    d2,d0
  28. 2:    swap    d0
  29.     clrw    d0
  30.     mulu    d3,d1        | r += v.l * u.l
  31.     addl    d1,d0
  32.     movel    a1,d3
  33.     movel    a0,d2
  34.     rts
  35.